package tcp;

import handler.inter.Handler;

import java.net.Socket;

public class ConnTask implements Runnable {

    private Socket conn;
    private Handler taskHandler;

    public ConnTask(Socket conn, Handler handler) {
        this.conn = conn;
        this.taskHandler = handler;
    }

    @Override
    public void run() {
        //  一定要显式的加 try-catch，否则子线程抛异常捕获不到
        try {
            taskHandler.handle(conn);
        } catch (Exception e) {
            e.printStackTrace();
        }

    }
}
